#include "Animation.hpp"

using namespace Typhoon;

Animation::Animation() {
	duration = 0;
	isDirty = false;


}

Animation::~Animation() {

}

Timeline<Vector2>& Animation::Position() {
	isDirty = true;
	return position;
}

Timeline<Vector2>& Animation::Scale() {
	isDirty = true;
	return scale;
}

Timeline<float>& Animation::Rotation() {
	isDirty = true;
	return rotation;
}

float Animation::Duration() {
	if (isDirty) {
		isDirty = false;
		CalcDuration();
	}
	return duration;
}

#define Max(x,y) ((x)>(y) ? (x) : (y))

void Animation::CalcDuration() {
	duration = Max(0, position.EndTime());
	duration = Max(duration, scale.EndTime());
	duration = Max(duration, rotation.EndTime());
}

